﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tosi
{
    class Feeder
    {
        private int tablesNr;
        private StatTable[] tables;
        
        private int statTableID = -1;
        private int fitnesTableID = -2;
        private int saverTableID = -3;

        private Statistics st;
        private GeneticAlgorithm ga;
        //private DataSaver ds;

        public Feeder(int nr, Statistics st2, GeneticAlgorithm genAlg)
        {
            tablesNr = nr;
            tables = new StatTable[nr];
            for (int i = 0; i < nr; i++)
                tables[i] = new StatTable();
            ga = genAlg;
            st = st2;
        }
        public void rotateTables()
        {
            statTableID++;
            if (statTableID >= 0)
            {
                if (statTableID == tablesNr)
                    statTableID = 0;
                tables[statTableID].init();
                st.setStatTable(ref tables[statTableID]);
            }
            fitnesTableID++;
            if (fitnesTableID >= 0)
            {
                if (fitnesTableID == tablesNr)
                    fitnesTableID = 0;
                ga.setStatTable(ref tables[fitnesTableID]);
                //ez meg hianyzik
            }
            saverTableID++;
            if (saverTableID >= 0)
            {
                if (saverTableID == tablesNr)
                    saverTableID = 0;
                //ds.setStatTable(ref tables[fitnesTableID]);
                //ez meg hianyzik
            }
        }
    }
}
